<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>约拍网后台管理</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>

    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <script type="text/javascript" th:src="@{/js/jquery-3.2.1.min.js}"></script>
    <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
    <script type="text/javascript" th:src="@{/js/lai.common.js}"></script>
</head>
<body class="layui-anim layui-anim-up">
<div class="x-nav">
        <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">评论管理</a>
        <a>
          <cite>查看反馈</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>


<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-form-text">
                        <div class="layui-form-item">
                            <div class="layui-input-inline">
                                <select name="userRole" onchange="searchFeedback()" id="selectRoleType">
                                    <option value="1">模特</option>
                                    <option value="2">摄影师</option>
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <input type="text" name="nickName" id="nickName" placeholder="请输入用户昵称"
                                       autocomplete="off"
                                       class="layui-input" onkeyup="searchFeedback()"> <!--键盘弹起就执行查找-->
                            </div>
                            <div class="layui-input-inline">
                                <input type="text" name="userPhone" id="userPhone" placeholder="请输入用户手机号"
                                       autocomplete="off"
                                       class="layui-input" onkeyup="searchFeedback()"> <!--键盘弹起就执行查找-->
                            </div>
                            <div class="layui-input-inline">
                                <button class="layui-btn" onclick="searchFeedback()" type="button"><i class="layui-icon">&#xe615;</i>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- 用户表-->
    <table class="layui-table" id="feedback-list" lay-filter="feedback-list" ></table>
</div>

<script type="text/html" id="userRole">
    {{# if(d.userRole==1) {}}
    <div class="layui-table-cell">模特</div>
    {{#} else if(d.userRole==2){ }}
    <div class="layui-table-cell">摄影师</div>
    {{#} else {}}
    {{# }}}
</script>

<script type="text/html" id="bar">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="showDetail">查看具体内容</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

<script>
    var table;
    layui.use('table',function () {
        table = layui.table;
        table.render({
            elem: '#feedback-list'
            , url: '/yuepai/admin/suggest/getAllFeedback.action'
            ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                ,layEvent: 'LAYTABLE_TIPS'
                ,icon: 'layui-icon-tips'
            }]
            , page: {
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'],
                groups: 5 //只显示 1 个连续页码
                , first: false //不显示首页
                , last: false //不显示尾页
            }
            , cols: [
                [
                    {field: 'nickName', title: '昵称',width:100}
                    , {field: 'userRole', title: '角色',  templet: '#userRole',sort:true}
                    , {field: 'userPhone', title: '手机号'}
                    , {field: 'content', title: '反馈内容'}
                    , {field: 'feedbackTime', title: '反馈时间'}
                    , {field: 'activity', title: '操作' ,templet: '#bar',width:230}
                ]
            ]
            , response: {
                statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
            }
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.status, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.list //解析数据列表
                };
            }
        });

        table.on('tool(feedback-list)',function (obj) {
            var layEvent = obj.event;
            var data = obj.data;
            // console.log("该行的数据为-->"+data);
            if(layEvent === "showDetail"){
                layer.open({
                    type: 2
                    , title: '反馈内容'
                    , area: [900+'px',500+'px']
                    , content: '/yuepai/admin/feedback-content'
                    , success: function (layero,index) {
                        console.log("data content:-->"+data.content)
                        var iframe = window['layui-layer-iframe' + index];
                        iframe.child(data.content);
                    }
                });
            }
            else if(layEvent === "del"){
                layer.confirm("确认删除吗？",{
                    btn: ['确认','取消']
                }, function () {
                    $.ajax({
                        url: '/yuepai/admin/suggest/deleteFeedback.action',
                        type: 'delete',
                        dataType: 'json',
                        data:{
                            feedbackId: data.feedbackId
                        },
                        beforeSend: LoadFunction,
                        error: errorFunction,
                        success: function (res) {
                            if(res.status==200){
                                layer.msg("删除成功！",{
                                    time: 1500,
                                    end: function(){
                                        location.reload();
                                    }
                                });
                            } else {
                                layer.msg(res.message);
                            }
                        }
                    })
                })
            }
        })
    });


    <!--查询用户 -->
    function searchFeedback() {
        var nickName = $("#nickName").val();
        var userRole = $("#selectRoleType").val();
        var userPhone = $("#userPhone").val();

        table.reload('feedback-list',{
            page: {
                curr: 1 //重新从第 1 页开始
            }
            , where: {
                nickName: nickName,
                userRole: userRole,
                userPhone: userPhone
            }
        });
    }



    function errorFunction() {
        layer.msg("出错了,请稍后再试");
    }

    function LoadFunction() {
        layer.msg('加载中', {
            icon: 16
            ,shade: 0.01     //透明度
        });
    }
</script>



</body>
</html>